package com.yfbao.horizon.schedule.tk.event;

import com.yfbao.horizon.schedule.tk.service.TrxTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
@Component
public class TestEventHandler {

    @Autowired
    private TrxTaskService trxTaskService;

    @EventListener
    public void handleCustomEvent(MyTestEvent event) {
        System.out.println("Received event: " + event.getMessage());
        trxTaskService.registAfterCommit();
    }
}
